from django.urls import path,include
from .views import *

# 对于视图集，做路由映射，可以通过drf提供的路由类来完成，自动路由映射生成路由
from rest_framework.routers import DefaultRouter

# trailing_slash 是否带斜杆 默认为True 为带斜杆
router = DefaultRouter(trailing_slash=True)

# 注册路由视图集
router.register('cate3',CateViewSet)
# router.register('cate4',CateViewSet2)
# 可查看路由
print(router.urls)

urlpatterns = [
    path("cate/", CateAPIView.as_view()),
    path("books/", BooksAPIView.as_view()),
    path("cate1/", CateGenericAPIView.as_view()),
    path("cate1/<int:pk>", CateDetailView.as_view()),
    path("cate2/", CateViewSet.as_view({'get':'list','post':'create'})),
    path("cate2/<int:pk>", CateViewSet.as_view({'get':'retrieve','put':'update','delete':'destroy'})),

    path('',include(router.urls))
]